using System.Drawing;
using System.Windows.Forms;
using ClientTools.Library.Interfaces;

//using ClientTools.Library.Nodes;

namespace ClientTools.Client.Controls.Versions
{
    public partial class UcVersions : BaseUserControl, IUserControl
    {

        #region Private Variables
        private IVersions actVersions;
        private INodes actNodes;

        private readonly UcVersionsTree ucTree;
        private readonly ucVersionsOldStyle ucOldStyle;

        #endregion

        public UcVersions()
        {
            InitializeComponent();

            ucTree = new UcVersionsTree();
            //tpNewVersion.Controls.Add(ucTree);
            Controls.Add(ucTree);
            ucTree.Dock = DockStyle.Fill;
            ucTree.Visible = true;

            //ucOldStyle = new ucVersionsOldStyle();
            //tpOldVersion.Controls.Add(ucOldStyle);
            //ucOldStyle.Dock = DockStyle.Fill;
            //ucOldStyle.Visible = true;

            //tabControl1.TabPages[1].Visible = false;
            //tabControl1.TabPages[2].Visible = false;
        }

        public void ClearData()
        {
            ucTree.ClearData();
            //ucOldStyle.ClearData();
            ucTree.Enabled = false;
            //ucOldStyle.Enabled = false;
        }

        #region I_UserControl Member

        public string Header
        {
            get { return "Versions"; }
        }

        public void SetData(Library.Settings.Profile profile)
        {
            ActProfile = profile;
            ActProfile.InitProvider();
            ActProvider = ActProfile.ProviderObject;
            
            if (!ImplementsVersions() || !ImplementsNodes())
            {
                ucTree.Enabled = false;
                ucOldStyle.Enabled = false;
                Enabled = false;
                return;
            }

            actVersions = (IVersions)ActProvider;
            actNodes = (INodes)ActProvider;
            ucTree.SetData(actVersions, actNodes);
            //ucOldStyle.SetData(actVersions);
            ClearData();
            Enabled = true;
            ucTree.Enabled = true;
            //ucOldStyle.Enabled = true;
        }

        public Image ButtonImage
        {
            get { return tsbVersions.Image; }
        }

        public int Sort
        {
            get { return 5; }
        }

        public bool ShowDelimiter
        {
            get { return false; }
        }

        public string ButtonText
        {
            get { return "Versions"; }
        }

        #endregion

    }
}
